package com.huo.thread.blockingqueue.producerconsumer;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.BlockingQueue;

public class Tmall {

	public  volatile static  int MAX_COUNT = 10;

	public BlockingQueue<Integer> queue = new ArrayBlockingQueue<>(MAX_COUNT);


	public  void push () {
		try {
			queue.put(1);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

	public synchronized void take () {
		try {
			queue.take();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}

	}
	public void size() {
		while (true) {
			System.out.println("当前队列的长队为：" + queue.size());
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}

}
